﻿package mlc.haxe.input;
import hsl.haxe.direct.DirectSignaler;
import hsl.haxe.Signaler;

/**
 * An input source that can hold multiple input sources inside. This class allows you to wire multiple input sources to one
 * console.
 */
class CompositeInputSource implements ConsoleInputSource {
	public var inputReceivedSignaler(default, null):Signaler<String>;
	/**
	 * Creates a new composite input source.
	 */
	public function new():Void {
		inputReceivedSignaler = new DirectSignaler<String>(this);
	}
	/**
	 * Adds an input source.
	 */
	public function addInputSource(value:ConsoleInputSource):Void {
		value.inputReceivedSignaler.addBubblingTarget(inputReceivedSignaler);
	}
	/**
	 * Removes an input source. If the passed input source has not been added, calling this method does nothing.
	 */
	public function removeInputSource(value:ConsoleInputSource):Void {
		value.inputReceivedSignaler.removeBubblingTarget(inputReceivedSignaler);
	}
}